﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminPage/Admin.master" AutoEventWireup="true" CodeFile="Agent.aspx.cs" Inherits="SBRUSYS_AdminPage_Agent" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style1
        {
            width: 100%;
            height: 59px;
        }
        .style3
        {
            width: 198px;
        }
        .style4
        {
            width: 93px;
        }
        .style5
        {
            width: 194px;
        }
        .style6
        {
            width: 164px;
        }
        .style7
        {
        }
        .style8
        {
        }
        .style9
        {
            width: 91px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
     <asp:Panel ID="Panel_addschool" runat="server">
     <ContentTemplate>
    <div style="height: 710px">
        <div>
            <table class="style1">
                <tr>
                    <td class="style4">
                        按地区搜索:</td>
                    <td class="style5">
                        <asp:DropDownList ID="Pro" runat="server" DataSourceID="SqlDataSource1Pro" 
                            DataTextField="province" DataValueField="ProID" Height="22px" 
                            Width="138px" AutoPostBack="True">
                        </asp:DropDownList>
                        省</td>
                    <td class="style3">
                        <asp:DropDownList ID="City" runat="server" DataSourceID="SqlDataSource1City" 
                            DataTextField="city" DataValueField="CityID" Height="22px" Width="138px" 
                            AutoPostBack="True">
                        </asp:DropDownList>
                        市</td>
                    <td class="style6">
                        <asp:DropDownList ID="Cou" runat="server" Height="22px" Width="132px" 
                            AutoPostBack="True" DataSourceID="SqlDataSource1Cou" DataTextField="SchoolName" 
                            DataValueField="SchoolId">
                        </asp:DropDownList>
                        学校</td>
                    <td>
                        <asp:Button ID="Button1" runat="server" Text="搜索" onclick="Button1_Click" />
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style5">
                        <asp:SqlDataSource ID="SqlDataSource1Pro" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                            SelectCommand="SELECT * FROM [ProvinceTable]"></asp:SqlDataSource>
                    </td>
                    <td class="style3">
                        <asp:SqlDataSource ID="SqlDataSource1City" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                            
                            SelectCommand="SELECT * FROM [CityTable] WHERE ([ProID] = @ProID)">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="Pro" Name="ProID" 
                                    PropertyName="SelectedValue" Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </td>
                    <td class="style6">
                        <asp:SqlDataSource ID="SqlDataSource1Cou" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                            
                            
                            SelectCommand="SELECT SchoolId, SchoolName, CountyId FROM SchoolTable WHERE (CountyId IN (SELECT CountyId FROM CountyTable WHERE (CityID = @cityID)))">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="City" Name="CityID" 
                                    PropertyName="SelectedValue" Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </td>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
            <div>
                <table class="style1">
                    <tr>
                        <td class="style9">
                            按名称搜索:</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox1" 
            runat="server" Width="159px" Height="22px"></asp:TextBox>
                        &nbsp;
                            <asp:Button ID="Button2" runat="server" Text="搜索" onclick="Button2_Click" />
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style9">
                            &nbsp;</td>
                        <td class="style8">
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style7" colspan="3">
                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                                DataKeyNames="agentID" DataSourceID="SqlDataSource1Agent" Width="818px" 
                                AllowPaging="True" AllowSorting="True">
                                <Columns>
                                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                    <asp:BoundField DataField="agentID" HeaderText="代理人ID" ReadOnly="True" 
                                        SortExpression="agentID" />
                                    <asp:BoundField DataField="SchoolId" HeaderText="学校ID" 
                                        SortExpression="SchoolId" />
                                    <asp:BoundField DataField="telephonenumber" HeaderText="联系电话" 
                                        SortExpression="telephonenumber" />
                                    <asp:BoundField DataField="IDcard" HeaderText="IDcard" 
                                        SortExpression="IDcard" />
                                    <asp:BoundField DataField="acpassword" HeaderText="密码" 
                                        SortExpression="acpassword" />
                                </Columns>
                            </asp:GridView>
                            <asp:SqlDataSource ID="SqlDataSource1Agent" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                                OldValuesParameterFormatString="original_{0}" 
                                SelectCommand="SELECT * FROM [Agent] WHERE ([SchoolId] = @SchoolId)">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="Cou" Name="SchoolId" 
                                        PropertyName="SelectedValue" Type="Int32" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td class="style7" colspan="3">
                            <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                                DataKeyNames="agentID" DataSourceID="SqlDataSource1agent2" Width="818px" 
                                AllowPaging="True" AllowSorting="True" Visible="False">
                                <Columns>
                                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                    <asp:BoundField DataField="agentID" HeaderText="代理人ID" ReadOnly="True" 
                                        SortExpression="agentID" />
                                    <asp:BoundField DataField="SchoolId" HeaderText="学校ID" 
                                        SortExpression="SchoolId" />
                                    <asp:BoundField DataField="telephonenumber" HeaderText="联系电话" 
                                        SortExpression="telephonenumber" />
                                    <asp:BoundField DataField="IDcard" HeaderText="IDcard" 
                                        SortExpression="IDcard" />
                                    <asp:BoundField DataField="acpassword" HeaderText="密码" 
                                        SortExpression="acpassword" />
                                </Columns>
                            </asp:GridView>
                            <asp:SqlDataSource ID="SqlDataSource1agent2" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                                
                                SelectCommand="SELECT * FROM [Agent] WHERE ([agentID] LIKE '%' + @agentID + '%')" 
                                ConflictDetection="CompareAllValues" 
                                DeleteCommand="DELETE FROM [Agent] WHERE [agentID] = @original_agentID AND (([SchoolId] = @original_SchoolId) OR ([SchoolId] IS NULL AND @original_SchoolId IS NULL)) AND [telephonenumber] = @original_telephonenumber AND [IDcard] = @original_IDcard AND [acpassword] = @original_acpassword" 
                                InsertCommand="INSERT INTO [Agent] ([agentID], [SchoolId], [telephonenumber], [IDcard], [acpassword]) VALUES (@agentID, @SchoolId, @telephonenumber, @IDcard, @acpassword)" 
                                OldValuesParameterFormatString="original_{0}" 
                                UpdateCommand="UPDATE [Agent] SET [SchoolId] = @SchoolId, [telephonenumber] = @telephonenumber, [IDcard] = @IDcard, [acpassword] = @acpassword WHERE [agentID] = @original_agentID AND (([SchoolId] = @original_SchoolId) OR ([SchoolId] IS NULL AND @original_SchoolId IS NULL)) AND [telephonenumber] = @original_telephonenumber AND [IDcard] = @original_IDcard AND [acpassword] = @original_acpassword">
                                <DeleteParameters>
                                    <asp:Parameter Name="original_agentID" Type="String" />
                                    <asp:Parameter Name="original_SchoolId" Type="Int32" />
                                    <asp:Parameter Name="original_telephonenumber" Type="String" />
                                    <asp:Parameter Name="original_IDcard" Type="String" />
                                    <asp:Parameter Name="original_acpassword" Type="String" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="agentID" Type="String" />
                                    <asp:Parameter Name="SchoolId" Type="Int32" />
                                    <asp:Parameter Name="telephonenumber" Type="String" />
                                    <asp:Parameter Name="IDcard" Type="String" />
                                    <asp:Parameter Name="acpassword" Type="String" />
                                </InsertParameters>
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="TextBox1" Name="agentID" PropertyName="Text" 
                                        Type="String" />
                                </SelectParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="SchoolId" Type="Int32" />
                                    <asp:Parameter Name="telephonenumber" Type="String" />
                                    <asp:Parameter Name="IDcard" Type="String" />
                                    <asp:Parameter Name="acpassword" Type="String" />
                                    <asp:Parameter Name="original_agentID" Type="String" />
                                    <asp:Parameter Name="original_SchoolId" Type="Int32" />
                                    <asp:Parameter Name="original_telephonenumber" Type="String" />
                                    <asp:Parameter Name="original_IDcard" Type="String" />
                                    <asp:Parameter Name="original_acpassword" Type="String" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>

     </asp:Panel>
     </ContentTemplate>
</asp:Content>

